
cc.Class({
    extends: cc.Component,

    properties: {
        W_Sprite:cc.Sprite,
        W_Content:cc.Label,
        PublisherSprite:cc.Sprite,
        PublisherLabel:cc.Label,
        Number:cc.Label
    },
    init:function (idx,data) {
        // this.getloader(data.url,"W_Sprite");
        this.getloader(data.portrait,"PublisherSprite");
        if(data.mandarin.length < 10){
            this.W_Content.node.y = -61;
            this.W_Content.string = data.mandarin;
        }else if(data.mandarin.length>10 && data.mandarin.length<15){
            this.W_Content.horizontalAlign = 0; 
            this.W_Content.string = data.mandarin;
        }else{
            this.W_Content.horizontalAlign = 0; 
            this.W_Content.string = data.mandarin.substring(0, 15)+"..."; 
        }
        this.PublisherLabel.string = data.openName.length > 5 ? data.openName.substring(0, 5)+"..." :data.openName;
        this.PublisherSprite.node.x = -Math.ceil(this.PublisherLabel.node.x/2);  
        this.Number.string = data.worksanswer;
        this.ClickId = data._id;
    },
    getloader:function(URL,name){
        var self = this;
        cc.loader.load({url: URL, type: 'png'}, function (err, texture) {
            self[name].spriteFrame = new cc.SpriteFrame(texture)
        })
    },
    onClick(){
      UserData.Fy_GuessDialect.getComponent("GuessDialect").info(this.ClickId);
    }
});
